1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
| [hadoop@hadoop ~]$ ll /usr/sbin/user* -rwxr-x---. 1 root root 118224 3月 14 2019 /usr/sbin/useradd -rwxr-x---. 1 root root 80400 3月 14 2019 /usr/sbin/userdel -rws--x--x. 1 root root 40312 6月 10 2014 /usr/sbin/userhelper -rwxr-x---. 1 root root 113856 3月 14 2019 /usr/sbin/usermod -rwsr-xr-x. 1 root root 11376 10月 31 2018 /usr/sbin/usernetctl [hadoop@hadoop ~]$ ll /usr/sbin/group* -rwxr-x---. 1 root root 65536 3月 14 2019 /usr/sbin/groupadd -rwxr-x---. 1 root root 57080 3月 14 2019 /usr/sbin/groupdel -rwxr-x---. 1 root root 57120 3月 14 2019 /usr/sbin/groupmems -rwxr-x---. 1 root root 76440 3月 14 2019 /usr/sbin/groupmod
添加用户【要有权限】一般使用root用户操作 [root@hadoop ~] [root@hadoop ~] uid=1001(k) gid=1001(k) 组=1001(k) [root@hadoop ~]
创建一个普通用户,默认创建这个名称的用户组k, 且设置这个用户 主组为k,且创建/home/k
查看有哪些用户目录 [root@hadoop ~] [root@hadoop home] 总用量 4 drwx------. 16 hadoop hadoop 4096 11月 20 15:55 hadoop drwx------. 2 k k 62 11月 20 16:25 k 所属用户 所属用户组
删除用户 [root@hadoop home] [root@hadoop home] id: k: no such user
因为k该组只有k用户,当这个用户删除时,组会校验就他自己,会自动删除,否则不会自动删除;但是home目录还在 [root@hadoop home] 总用量 4 drwx------. 16 hadoop hadoop 4096 11月 20 15:55 hadoop drwx------. 2 1001 1001 62 11月 20 16:25 k
重新创建k [root@hadoop home] useradd:警告:此主目录已经存在。 不从 skel 目录里向其中复制任何文件。 正在创建信箱文件: 文件已存在 [root@hadoop home] uid=1001(k) gid=1001(k) 组=1001(k) [root@hadoop home]
模拟切换用户丢失样式 [root@hadoop k] 总用量 12 drwx------. 2 k k 62 11月 20 16:25 . drwxr-xr-x. 4 root root 29 11月 20 16:25 .. -rw-r--r--. 1 k k 18 10月 31 2018 .bash_logout -rw-r--r--. 1 k k 193 10月 31 2018 .bash_profile -rw-r--r--. 1 k k 231 10月 31 2018 .bashrc [root@hadoop k] [root@hadoop k] -bash-4.2$ -bash-4.2$
修正样式 [root@hadoop k] cp: omitting directory ‘/etc/skel/.’ cp: omitting directory ‘/etc/skel/..’ [root@hadoop k] total 12 drwx------ 2 k k 59 Nov 16 21:32 . drwxr-xr-x. 5 root root 44 Nov 16 21:16 .. -rw-r--r-- 1 root root 18 Nov 16 21:32 .bash_logout -rw-r--r-- 1 root root 193 Nov 16 21:32 .bash_profile -rw-r--r-- 1 root root 231 Nov 16 21:32 .bashrc [root@hadoop k]
[root@hadoop k] total 12 drwx------. 4 k k 91 11月 20 16:37 . drwxr-xr-x. 4 root root 29 11月 20 16:25 .. -rw-r--r--. 1 k k 18 11月 20 16:37 .bash_logout -rw-r--r--. 1 k k 193 11月 20 16:37 .bash_profile -rw-r--r--. 1 k k 231 11月 20 16:37 .bashrc [root@hadoop k] [root@hadoop k] 上一次登录:三 11月 20 16:36:51 CST 2019pts/1 上 [k@hadoop ~]$
添加ruoze用户到另外一个组 bigdata [root@hadoop k] [root@hadoop k] bigdata:x:1002: [root@hadoop k] [root@hadoop k] uid=1001(k) gid=1001(k) 组=1001(k),1002(bigdata) [root@hadoop k]
修改bigdata为k的主组 [root@hadoop k] [root@hadoop k] uid=1001(k) gid=1002(bigdata) 组=1002(bigdata) [root@hadoop k] [root@hadoop k] uid=1001(k) gid=1002(bigdata) 组=1002(bigdata),1001(k)
|